﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MyMusicPlay._4._0.Manager
{
    public class TimerManager : ManagerBase
    {
        /// <summary>
        /// 总开关
        /// </summary>
        public static bool totalSwitch = true;

        /// <summary>
        /// key:间隔毫秒
        /// </summary>
        private static readonly Dictionary<int, TimeData> _timeList = new();

        public TimerManager()
        { }

        public TimeData GetTimerData(int millisecond)
        {
            TimeData timeData;
            if (_timeList.ContainsKey(millisecond))
            {
                timeData = _timeList[millisecond];
            }
            else
            {
                timeData = new TimeData(millisecond);
                _timeList.TryAdd(millisecond, timeData);
            }
            return timeData;
        }

        public void RemoveTimerData(int milliseound, int index)
        {
            var TimeData = GetTimerData(milliseound);
            TimeData.DeleteAction(index);
        }
    }
}
